<?php

namespace app\admin\controller;

use think\Controller;
use think\Request;

class Carmichael extends Base
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        $list=db('carmichael')->select();
        $this->assign('list',$list);
        $info=db('ship_card')->select();
        $this->assign('info',$info);
        return $this->fetch();
    }
    /**
     * 显示资源列表
     *会员卡
     * @return \think\Response
     */
    public function type_index()
    {
        $title=input('title');
        $where =array();
        if ($title){
            $where['card']=['like','%'.$title.'%'];
        }
        $info=db('ship_card')->where($where)->select();
        $this->assign('info',$info);
        return $this->fetch();
    }
    /**
     * 显示创建资源表单页.
     *
     * @return \think\Response
     */
    public function create()
    {
        return $this->fetch();
    }

    /**
     * 保存新建的资源
     *
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function save(Request $request)
    {
        $inputdata=input();
        $data['name']=$inputdata['name'];
        $data['count']=$inputdata['count'];
        $data['tian']=$inputdata['tian'];
        $data['img']=$inputdata['img'];
        $data['status']=1;
        $data['remarks']=$inputdata['remarks'];
        $data['time']=time();
        $inputmodel=model('carmichael');
        $list=$inputmodel->creat($data);
//        $list=db('explain')->insert($data);
        if($list){
            $this->success('添加成功',url('carmichael/index'));
        }else{
            $this->error('添加失败');
        }
    }
}
